﻿module.exports =
`
#ifdef GL_ES
precision mediump float;
#endif
 
varying vec2 v_texCoord;
varying vec4 v_fragmentColor;


#define outlineSize 10.*sin(2.*CC_Time.y)
#define outlineColor vec3(abs(sin(outlineSize/10.)),0.,0.)
#define textureSize vec2(215.0,299.0)

int getIsStrokeWithAngel(float angel)
{
    int stroke = 0;
    float rad = angel * 0.01745329252;
    float a = texture2D(CC_Texture0, vec2(v_texCoord.x + outlineSize * cos(rad) / textureSize.x, v_texCoord.y + outlineSize * sin(rad) / textureSize.y)).a; 
    if (a >= 0.01)
    {
        stroke = 1;
    }
    return stroke;
}
void main() {
    vec4 myC = texture2D(CC_Texture0, vec2(v_texCoord.x, v_texCoord.y)); 
    if (myC.a >= 0.5)
    {
        gl_FragColor =  v_fragmentColor*myC;
        return;
    }
    int strokeCount = 0;
    strokeCount += getIsStrokeWithAngel(0.0);
    strokeCount += getIsStrokeWithAngel(30.0);
    strokeCount += getIsStrokeWithAngel(60.0);
    strokeCount += getIsStrokeWithAngel(90.0);
    strokeCount += getIsStrokeWithAngel(120.0);
    strokeCount += getIsStrokeWithAngel(150.0);
    strokeCount += getIsStrokeWithAngel(180.0);
    strokeCount += getIsStrokeWithAngel(210.0);
    strokeCount += getIsStrokeWithAngel(240.0);
    strokeCount += getIsStrokeWithAngel(270.0);
    strokeCount += getIsStrokeWithAngel(300.0);
    strokeCount += getIsStrokeWithAngel(330.0);
    float dis = pow( pow(abs(v_texCoord.x-0.5),2.) + pow(abs(v_texCoord.y-0.5),2.) , 4.);
    if (strokeCount > 0) 
    {
        myC.rgb = outlineColor;
        myC.a = 1.0*dis;
    }
    gl_FragColor = v_fragmentColor * myC;
}
`